package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import org.antlr.v4.runtime.misc.NotNull;
import org.zhadoop.stream.api.opereators.JoinType;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.CrossJoinContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.FullJoinContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.InnerJoinContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.LeftJoinContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.NaturalJoinContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.RightJoinContext;

/**
 * join 类型语法遍历
 * 
 * @author zwd
 *
 */
public class JoinTokenVisitor extends AbsCQLParserBaseVisitor<JoinType> {

	private JoinType context = null;

	public JoinTokenVisitor() {
	}

	@Override
	protected JoinType defaultResult() {
		return context;
	}

	@Override
	public JoinType visitInnerJoin(@NotNull InnerJoinContext ctx) {
		context = JoinType.INNER_JOIN;
		return context;
	}

	@Override
	public JoinType visitLeftJoin(@NotNull LeftJoinContext ctx) {
		context = JoinType.LEFT_OUTER_JOIN;
		return context;
	}

	@Override
	public JoinType visitRightJoin(@NotNull RightJoinContext ctx) {
		context = JoinType.RIGHT_OUTER_JOIN;
		return context;
	}

	@Override
	public JoinType visitFullJoin(@NotNull FullJoinContext ctx) {
		context = JoinType.FULL_OUTER_JOIN;
		return context;
	}

	@Override
	public JoinType visitCrossJoin(@NotNull CrossJoinContext ctx) {
		context = JoinType.CROSS_JOIN;
		return context;
	}

	@Override
	public JoinType visitNaturalJoin(@NotNull NaturalJoinContext ctx) {
		context = JoinType.NATURAL_JOIN;
		return context;
	}

}
